

function saveSchedule(){
    var startTime = $("#startTime").val();
    if(startTime == ""){
        alert("开始时间不能为空");
        return;
    }
    var endTime = $("#endTime").val();
    if(endTime == ""){
        alert("结束时间不能为空");
        return;
    }

    var d1 = new Date(startTime.replace(/\-/g, "\/"));
    var d2 = new Date(endTime.replace(/\-/g, "\/"));
    if(d1 >= d2)
    {
        alert("开始时间不能大于结束时间！");
        return;
    }

    var place = $("#place").val();
    //if(place == ""){
    //    alert("地点不能为空");
    //    return;
    //}
    var reminderDate = $("#reminderDate").val();
    if(reminderDate == ""){
        alert("提醒日期不能为空");
        return;
    }
    var workArrangement = $("#workArrangement").val();
    if(workArrangement == ""){
        alert("工作安排不能为空");
        return;
    }
    var remarks = $("#remarks").val();
    //if(remarks == ""){
    //    alert("备注不能为空");
    //    return;
    //}
    var completeStatus = $("#completeStatus").val();
    //if(completeStatus == ""){
    //    alert("完成状态不能为空");
    //    return;
    //}

    var ajax = new $ax("/personalschedule/save", function (data) {
        // 成功
        if (data.status == "true") {
            alert("添加成功");
            window.location.href='schedule.html';
        } else {
            alert("添加失败");
        }

    }, function (data) {
        // 失败
        alert("访问失败");
        errorAjax();
        alert("添加失败");
    });

    ajax.setToken(cookie.get("token"));
    ajax.set("startTime",startTime);
    ajax.set("endTime",endTime);
    ajax.set("place",place);
    ajax.set("reminderDate",reminderDate);
    ajax.set("workArrangement",workArrangement);
    ajax.set("remarks",remarks);
    ajax.set("completeStatus",completeStatus);
    ajax.start();

}

function showDateYYYYmmdd(id) {
    $('#'+id).datetimepicker({
        //language:  'fr',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1,
        format: 'yyyy-mm-dd hh:mm',
        language: 'zh'
    });
}
function showDatehhmm(id) {
    $('#'+id).datetimepicker({
        //language:  'fr',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1,
        format: 'hh:mm',
        language: 'zh'
    });
}
function onWeekDate(id){
    $('#'+id).datetimepicker({
        //language:  'fr',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1,
        format: 'yyyy-mm-dd hh:mm',
        language: 'zh'
    });
}

//return y + '-' + m + '-' + d +' '+h+':'+minute;
function formatDateTimeYMDHM(inputTime) {
    var date = new Date(inputTime);
    var y = date.getFullYear();
    var m = date.getMonth() + 1;
    m = m < 10 ? ('0' + m) : m;
    var d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    var h = date.getHours();
    h = h < 10 ? ('0' + h) : h;
    var minute = date.getMinutes();
    var second = date.getSeconds();
    minute = minute < 10 ? ('0' + minute) : minute;
    second = second < 10 ? ('0' + second) : second;
    // return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
    return y + '-' + m + '-' + d +' '+h+':'+minute;
};